<?php
/**
 * @file : brandrelstar.php
 * @date : 2015-01-04
 */
namespace haibao\cms\data;

use haibao\cms\model\filter\BrandRelStar as BrandRelStarFilter;

class BrandRelStar extends \haibao\cms\data\BaseMysql{

    public function __construct(){
        parent::__construct('\haibao\cms\model\data\BrandRelStar');
    }

    
    /**
     * 根据明星ID获取明星与明星关联关系（单个ID）
     * @param Int $celebrityId 明星ID
     */
    public function getCelebrityRelByCelebrityId($celebrityId){
    
    	$filter = new BrandRelStarFilter();
    	$filter->select(array(
    			BrandRelStarFilter::CONDITION_FIELD_NAME_BRAND_ID,
    			BrandRelStarFilter::CONDITION_FIELD_NAME_COOPERATE_TIME,
    	));
    	
    	$brandFilter = new \haibao\cms\model\filter\Brand();
    	$brandFilter->select(array(
    		\haibao\cms\model\filter\Brand::CONDITION_FIELD_NAME_NAMECN,
    		\haibao\cms\model\filter\Brand::CONDITION_FIELD_NAME_NAMEEN
    	));
    	
    	$filter->where(BrandRelStarFilter::CONDITION_FIELD_NAME_CELEBRITY_ID,\haibao\frame\data\query\Condition::CONDITION_EQUAL,$celebrityId);
    	$filter->leftjoin($brandFilter,null,BrandRelStarFilter::CONDITION_FIELD_NAME_BRAND_ID,'Id',BrandRelStarFilter::CONDITION_FIELD_NAME_BRAND_NAME,false);

        return $this->getAll($filter);
    }
    
    
}
